import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { lo } from 'element-plus/es/locales.mjs'

export const useLoginStore = defineStore('LoginStore', () => {
  //1. 定义俩个共享的数据
  let loginUsername = ref('用户名')
  let loginToken = ref('')

  //2. 定义一个方法,用来设置这俩个值
  function setLoginInfo(username: string, token: string) {
    loginUsername.value = username
    loginToken.value = token
  }
  //3. 返回出去,这样子外部才能够使用到
  return {loginUsername,loginToken,setLoginInfo}
},{
  persist:{
    key:'loginStore',
    storage:localStorage
  }
})